{extend name="layout" /}
{block name="css"}<link rel="stylesheet" href="/style/admin.css" media="all">{/block}
{block name="title"}{/block}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-app-project-issue-search">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-block">
                        <select name="type">
                            <option value="">请选择</option>
                            <option value="0">任务</option>
                            <option value="1">需求</option>
                            <option value="2">缺陷</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-order" lay-submit lay-filter="LAY-app-project-issue-search-submit">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-list" data-type="batchdel">删除</button>
                <button class="layui-btn layuiadmin-btn-list" data-type="add">添加</button>
            </div>
            <table id="LAY-app-project-issue" lay-filter="LAY-app-project-issue"></table>
            <script type="text/html" id="typeTpl">
                {{#  if(d.type == 0){ }}
                <button class="layui-btn layui-btn-normal layui-btn-xs">任务</button>
                {{#  } else if(d.type == 1){ }}
                <button class="layui-btn layui-btn-primary layui-btn-xs">需求</button>
                {{#  } else{ }}
                <button class="layui-btn layui-btn-warm layui-btn-xs">缺陷</button>
                {{#  } }}
            </script>
            <script type="text/html" id="progressTpl">
                <div class="layui-progress layuiadmin-order-progress" lay-filter="progress-" + {{ d.orderid }} +"">
                    <div class="layui-progress-bar layui-bg-blue" lay-percent={{ d.progress }}></div>
                </div>
            </script>
            <script type="text/html" id="buttonTpl">
                {{#  if(d.status == '已处理'){ }}
                <button class="layui-btn layui-btn-normal layui-btn-xs">已处理</button>
                {{#  } else if(d.status == '未分配'){ }}
                <button class="layui-btn layui-btn-primary layui-btn-xs">未分配</button>
                {{#  } else{ }}
                <button class="layui-btn layui-btn-warm layui-btn-xs">处理中</button>
                {{#  } }}
            </script>
            <script type="text/html" id="LAY-app-project-issue-bar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
                        class="layui-icon layui-icon-edit"></i>编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
                        class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['index', 'project', 'table'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , form = layui.form
            , table = layui.table;

        form.render(null, 'LAY-app-project-issue-search');

        //监听搜索
        form.on('submit(LAY-app-project-issue-search-submit)', function (data) {
            var field = data.field;

            //执行重载
            table.reload('LAY-app-project-issue', {
                where: field
            });
        });

        var active = {
            batchdel: function () {
                var checkStatus = table.checkStatus('LAY-app-content-list')
                    , checkData = checkStatus.data; //得到选中的数据

                if (checkData.length === 0) {
                    return layer.msg('请选择数据');
                }

                layer.confirm('确定删除吗？', function (index) {

                    //执行 Ajax 后重载
                    /*
                    admin.req({
                      url: 'xxx'
                      //,……
                    });
                    */
                    table.reload('LAY-app-project-issue');
                    layer.msg('已删除');
                });
            },
            add: function () {
                add('添加任务', 'issue', '550px', '550px', 'LAY-app-project-issue');
            }
        };

        $('.layui-btn.layuiadmin-btn-list').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
{/block}